﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.IO;
using DXApplicationTangche.UC.货号管理.service;
using DevExpress.XtraGrid.Demos.util;

namespace DXApplicationTangche.UC.货号管理
{
    public partial class Form款式添加外观 : DevExpress.XtraEditors.XtraForm
    {
        private Model款式加外观 model;
        private String styleSonCode;
        private CraftFacadeDesignImportDTO craftFacadeDesignImportDTO = new CraftFacadeDesignImportDTO();
        public Form款式添加外观(String styleSonCode, FileInfo[] files)
        {
            InitializeComponent();
            this.styleSonCode = styleSonCode;
            this.model = new Model款式加外观(files);
            if (this.model.filePictureNames.Count > 0)
            {
                this.craftFacadeDesignImportDTO = 款式迭代Service.getCraftFacadeDesignImportInfo(this.model.filePictureNames);
                this.gridControl设计点文件.DataSource 
                    = this.model.build未匹配(this.craftFacadeDesignImportDTO.invalidFacadeValues).newFacadeDesignVOs;
                this.gridControl设计点.DataSource = this.craftFacadeDesignImportDTO.craftFacadeDesignDTOList;
            }
        }

        private void simpleButton款式加外观_Click(object sender, EventArgs e)
        {
            Dictionary<String, String> craftFacadeStyleDesignIdAndDesignIdMap = new Dictionary<string, string>();
            foreach (CraftFacadeDesignDTO item in this.craftFacadeDesignImportDTO.craftFacadeDesignDTOList)
            {
                craftFacadeStyleDesignIdAndDesignIdMap.Add(new FunctionHelper().Uuid, item.id);
            }
            String re = 款式迭代Service.saveCraftFacadeStyleDesign(
                this.styleSonCode,
                craftFacadeStyleDesignIdAndDesignIdMap
                );
            this.Close();
        }

        private void 补充设计点信息ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form外观设计 form = new Form外观设计(
                FunctionHelper.getTileView(this.tileView设计点文件, this.tileView设计点文件.FocusedRowHandle, "facadeFileName"),
                (Image)this.tileView设计点文件.GetRowCellValue(this.tileView设计点文件.FocusedRowHandle, "facadePicture")
                );
            form.ShowDialog();
            if (!String.IsNullOrEmpty(form.id))
            {
                this.craftFacadeDesignImportDTO.craftFacadeDesignDTOList.Add(款式迭代Service.getCraftFacadeDesignDTO(form.id));
                this.gridView设计点.RefreshData();
            }
        }
    }
    
}